/*
 * @Author: fanjs
 * @Date: 2025-03-22 19:52:11
 * @Description: 账单表单验证
 */
import { addToast } from '@heroui/react';
import type { EmailItem } from '../types';

// 表单验证规则
export const validateConfigFields = [
  { field: 'company', value: '', msg: '请选择邮箱类型' },
  { field: 'email_account', value: '', msg: '请输入邮箱地址' },
  { field: 'protocol', value: '', msg: '请选择协议' },
  { field: 'pass', value: '', msg: '请输入密钥' },
];

// 验证 配置表单
export const validateConfigForm = (formData: Partial<EmailItem>) => {
  for (const field of validateConfigFields) {
    const value = formData[field.field as keyof EmailItem];
    if (!value) {
      addToast({ title: field.msg });
      return false;
    }
  }
  return true;
};
